package cn.xjfcloud.onedriveserver.init;

import java.util.HashSet;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@Configuration
public class Swagger2Config {

	 public static final HashSet<String> consumes = new HashSet<String>() {{
	        add("application/x-www-form-urlencoded");
	        add("multipart/form-data");
	        add("application/json");
	    }};
	
	@Bean
	public Docket createRestApi() {
		return new Docket(DocumentationType.SWAGGER_2)
				.apiInfo(apiInfo())
				.select()
				.apis(RequestHandlerSelectors.basePackage("cn.xjfcloud.onedriveserver.controller"))
				.paths(PathSelectors.any())
				.build()
				.consumes(consumes);
	}
	
	private ApiInfo apiInfo() {
		return new ApiInfoBuilder()
				.title("OnedriveServer api文档")
				.description("OnedriveServer api文档")
				.termsOfServiceUrl("localhost:8081/swagger")
				.version("1.0")
				.build();
	}
}
